Libraries

Load data

file_path_t <- "~/rocker/RDEB/ccc_cellchat.t.2.rds"
cellchat.t <- readRDS(file_path_t)
file_path_s <- "~/rocker/RDEB/ccc_cellchat.s.2.rds"
cellchat.s <- readRDS(file_path_s)

Circle diagramm for skin, SCC

cellchat.t@netP$pathways
##  [1] "COLLAGEN"   "LAMININ"    "MIF"        "MHC-I"      "FN1"       
##  [6] "CD99"       "THBS"       "VISFATIN"   "MHC-II"     "APP"       
## [11] "CLEC"       "MK"         "ADGRE5"     "GALECTIN"   "CXCL"      
## [16] "TGFb"       "PARs"       "SEMA4"      "PTPRM"      "SEMA3"     
## [21] "TENASCIN"   "CD45"       "ANNEXIN"    "PTN"        "ICAM"      
## [26] "ITGB2"      "GAS"        "EGF"        "PECAM1"     "ANGPTL"    
## [31] "TNF"        "CD22"       "JAM"        "CD46"       "VEGF"      
## [36] "NOTCH"      "THY1"       "PERIOSTIN"  "CCL"        "SELE"      
## [41] "MPZ"        "ncWNT"      "NEGR"       "ALCAM"      "CD6"       
## [46] "ANGPT"      "NECTIN"     "COMPLEMENT" "VCAM"       "SELL"      
## [51] "FGF"        "PDGF"       "PROS"       "CADM"       "HSPG"      
## [56] "CALCR"      "CD226"      "BAFF"       "CD86"       "NCAM"      
## [61] "IL16"       "IL1"        "SEMA6"      "EPHB"       "BMP"       
## [66] "EPHA"       "LCK"        "TIGIT"      "IFN-II"     "GRN"       
## [71] "ESAM"       "NRXN"       "KIT"        "CDH5"       "CSF"       
## [76] "SELPLG"     "CDH"        "EDN"        "BTLA"       "IL2"       
## [81] "CNTN"       "CD70"       "TWEAK"      "IGF"        "APRIL"     
## [86] "TRAIL"      "VISTA"      "NRG"        "APJ"        "RELN"      
## [91] "IL6"        "CD34"       "HGF"        "L1CAM"      "SN"        
## [96] "CD137"      "WNT"
pathways.show.t <- c("COLLAGEN", "LAMININ", "MIF", "MHC-I", "FN1", "CD99", "THBS", "VISFATIN", "MHC-II", "APP", "CLEC", "MK", "ADGRE5", "GALECTIN", "CXCL", "TGFb", "PARs", "SEMA4", "PTPRM", "SEMA3", "TENASCIN", "CD45", "ANNEXIN", "PTN", "ICAM", "ITGB2", "GAS", "EGF", "PECAM1", "ANGPTL", "TNF", "CD22", "JAM", "CD46", "VEGF", "NOTCH", "THY1", "PERIOSTIN", "CCL", "SELE", "MPZ", "ncWNT", "NEGR", "ALCAM", "CD6", "ANGPT", "NECTIN", "COMPLEMENT", "VCAM", "SELL", "FGF", "PDGF", "PROS", "CADM", "HSPG", "CALCR", "CD226", "BAFF", "CD86", "NCAM", "IL16", "IL1", "SEMA6", "EPHB", "BMP", "EPHA", "LCK", "TIGIT", "IFN-II", "GRN", "ESAM", "NRXN", "KIT", "CDH5", "CSF", "SELPLG", "CDH", "EDN", "BTLA", "IL2", "CNTN", "CD70", "TWEAK", "IGF", "APRIL", "TRAIL", "VISTA", "NRG", "APJ", "RELN", "IL6", "CD34", "HGF", "L1CAM", "SN", "CD137", "WNT")

cellchat.s@netP$pathways
##  [1] "COLLAGEN"   "LAMININ"    "MHC-I"      "MIF"        "FN1"       
##  [6] "CD99"       "THBS"       "VISFATIN"   "CLEC"       "APP"       
## [11] "ADGRE5"     "MHC-II"     "CXCL"       "ICAM"       "SELE"      
## [16] "MK"         "CD45"       "PTN"        "PTPRM"      "ITGB2"     
## [21] "PARs"       "CD22"       "ALCAM"      "CD6"        "TGFb"      
## [26] "ANGPTL"     "VEGF"       "JAM"        "CD46"       "ANNEXIN"   
## [31] "PECAM1"     "GAS"        "FGF"        "SEMA3"      "MPZ"       
## [36] "CADM"       "NOTCH"      "TENASCIN"   "VCAM"       "NEGR"      
## [41] "PERIOSTIN"  "NECTIN"     "IL6"        "ANGPT"      "SEMA4"     
## [46] "THY1"       "EGF"        "TIGIT"      "TNF"        "PDGF"      
## [51] "CCL"        "SEMA7"      "CALCR"      "NCAM"       "IL2"       
## [56] "ncWNT"      "IFN-II"     "EPHA"       "PROS"       "IL16"      
## [61] "LCK"        "EPHB"       "CD226"      "HSPG"       "SELL"      
## [66] "KIT"        "BMP"        "ESAM"       "CD70"       "CDH5"      
## [71] "LIGHT"      "CD86"       "DESMOSOME"  "BAFF"       "SEMA6"     
## [76] "TRAIL"      "COMPLEMENT" "IGF"        "CDH1"       "SELPLG"    
## [81] "IL1"        "FASLG"      "EDN"        "TWEAK"      "NRXN"      
## [86] "IL10"       "CD34"       "CSF3"       "LIFR"       "CSF"       
## [91] "NRG"        "L1CAM"      "CDH"        "WNT"        "VEGI"
pathways.show.s <- c("COLLAGEN", "LAMININ", "MHC-I", "MIF", "FN1", "CD99", "THBS", "VISFATIN", "CLEC", "APP", "ADGRE5", "MHC-II", "CXCL", "ICAM", "SELE", "MK", "CD45", "PTN", "PTPRM", "ITGB2", "PARs", "CD22", "ALCAM", "CD6", "TGFb", "ANGPTL", "VEGF", "JAM", "CD46", "ANNEXIN", "PECAM1", "GAS", "FGF", "SEMA3", "MPZ", "CADM", "NOTCH", "TENASCIN", "VCAM", "NEGR", "PERIOSTIN", "NECTIN", "IL6", "ANGPT", "SEMA4", "THY1", "EGF", "TIGIT", "TNF", "PDGF", "CCL", "SEMA7", "CALCR", "NCAM", "IL2", "ncWNT", "IFN-II", "EPHA", "PROS", "IL16", "LCK", "EPHB", "CD226", "HSPG", "SELL", "KIT", "BMP", "ESAM", "CD70", "CDH5", "LIGHT", "CD86", "DESMOSOME", "BAFF", "SEMA6", "TRAIL", "COMPLEMENT", "IGF", "CDH1", "SELPLG", "IL1", "FASLG", "EDN", "TWEAK", "NRXN", "IL10", "CD34", "CSF3", "LIFR", "CSF", "NRG", "L1CAM", "CDH", "WNT", "VEGI")

# Output PDF setup
pdf("~/rocker/RDEB/thesis/Chord_diagram_SCC.pdf")
netVisual_aggregate(cellchat.t, signaling = pathways.show.t, layout = "chord")

# Output PDF setup
pdf("~/rocker/RDEB/thesis/Chord_diagram_Skin.pdf")
netVisual_aggregate(cellchat.s, signaling = pathways.show.s, layout = "chord")

Heatmap SCC, heatmap skin

# Set up PDF output for SCC, saving directly to the desired directory
pdf("~/rocker/RDEB/thesis/Heatmap_SCC_Interaction_count.pdf", width = 16, height = 8)

# Interaction count heatmap for SCC
gg1_tumor <- netVisual_heatmap(cellchat.t, measure = "count")
## Do heatmap based on a single object
plot(gg1_tumor)

# Set up PDF output for Skin, also saving directly to the desired directory
pdf("~/rocker/RDEB/thesis/Heatmap_Skin_Interaction_count.pdf", width = 16, height = 8)

# Interaction count heatmap for Skin
gg1_skin <- netVisual_heatmap(cellchat.s, measure = "count")
## Do heatmap based on a single object
plot(gg1_skin)

There are no T naive CD4 in skin so lets exclude them from analysis

# Define the identifier for naive CD4 T cells
naive_CD4_identifier <- "T naive CD4"

# Filter out interactions involving naive CD4 T cells from the SCC dataset
cellchat.t.sC <- subsetCommunication(cellchat.t, thresh=1) %>%
                 filter(!(source == naive_CD4_identifier | 
                            target == naive_CD4_identifier))

# Filter out interactions involving naive CD4 T cells from the skin dataset
cellchat.s.sC <- subsetCommunication(cellchat.s, thresh=1) %>%
                 filter(!(source == naive_CD4_identifier | 
                            target == naive_CD4_identifier))

# merge the two data frames
merged_data <- merge(cellchat.t.sC, cellchat.s.sC, 
                     by = c("source", "target", "ligand", "receptor", 
                            "interaction_name","interaction_name_2", 
                            "pathway_name", "annotation", "evidence"),
                     all = TRUE)

Replace NA values with 0

merged_data <- merged_data %>%
  mutate(
    prob.t = ifelse(is.na(prob.x), 0, prob.x),
    prob.s = ifelse(is.na(prob.y), 0, prob.y),
    pval.t = ifelse(is.na(pval.x), 0, pval.x),
    pval.s = ifelse(is.na(pval.y), 0, pval.y)
  ) %>%
  select(-prob.x, -prob.y, -pval.x, -pval.y) # delete columns 

Calculating the difference between probabilities SCC - skin

merged_data <- merged_data %>%
  mutate(prob.delta = prob.t - prob.s) %>%
  arrange(desc(abs(prob.delta)))

Count interactions for skin and SCC (actual numeric difference )

# Create the summary data frame with the desired columns
merged_df.interactions <- merged_data %>%
  group_by(source, target) %>%
  summarise(
    Tumor_Interactions = sum(prob.t > 0),
    Skin_Interactions = sum(prob.s > 0),
    Interaction_Difference = Tumor_Interactions - Skin_Interactions,
    Interaction_Difference_abs = sum(xor(prob.t == 0, prob.s == 0)),
    .groups = 'drop'
  )

# Print the interaction summary data frame
print(merged_df.interactions)
## # A tibble: 688 × 6
##    source target     Tumor_Interactions Skin_Interactions Interaction_Difference
##    <fct>  <fct>                   <int>             <int>                  <int>
##  1 B cell B cell                      8                10                     -2
##  2 B cell Endothel                   14                 7                      7
##  3 B cell Endothel_…                 20                28                     -8
##  4 B cell Fibroblas…                 17                22                     -5
##  5 B cell Fibroblas…                  8                10                     -2
##  6 B cell Fibroblas…                  3                 2                      1
##  7 B cell Fibroblas…                 19                17                      2
##  8 B cell Fibroblas…                 15                30                    -15
##  9 B cell T gd                       12                20                     -8
## 10 B cell Keratinoc…                  9                17                     -8
## # ℹ 678 more rows
## # ℹ 1 more variable: Interaction_Difference_abs <int>

Bubble plot based on counts difference

# Create a point plot with color and size adjustments
point_plot <- ggplot(merged_df.interactions, aes(x = target, y = source)) +
  geom_point(aes(size = Interaction_Difference_abs, color = Interaction_Difference), shape = 20) +
  scale_size_continuous(name = "Absolute Interaction Difference", range = c(1, 11)) + 
  scale_color_gradient2(name = "Interactions Difference",
                        high = rgb(178/255, 24/255, 43/255), 
                        mid = "white",
                        low = rgb(33/255, 102/255, 172/255),
                        midpoint = 0) + # Diverging color scale
  labs(title = "Difference in Number of Interactions (SCC vs Skin)",
       x = "Target cells (receptor)",
       y = "Source cells (ligand)",
       color = "Interactions Difference",
       size = "Abs Interaction Diff") +
  theme_minimal() +
  theme(
    axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1, size = 10),
    axis.text.y = element_text(size = 10),
    axis.title = element_text(size = 12),
    plot.title = element_text(size = 14, face = "bold"),
    legend.position = "right",
    legend.direction = "vertical",
    legend.title = element_text(size = 12),
    legend.text = element_text(size = 10)
  )

# Print the point plot
print(point_plot)

# Save the plot
ggsave("~/rocker/RDEB/thesis/bubble_plot_based_on_interactions_difference.png",
       plot = point_plot,
       width = 10,
       height = 8,
       dpi = 300)

Number of interactions per source cell (ligand) in SCC - skin

# Compute interaction counts for each dataset, excluding T naive CD4
df.t <- cellchat.t %>%
  subsetCommunication(thresh = NA) %>%
  filter(source != naive_CD4_identifier & target != naive_CD4_identifier) %>% 
  dplyr::as_tibble() %>% 
  dplyr::count(source) %>% 
  dplyr::rename(Tumor_Interactions = n)
df.s <- cellchat.s %>% # no need to exclude, since in skin there is nothing 
  subsetCommunication(thresh = NA) %>% 
  dplyr::as_tibble() %>% 
  dplyr::count(source) %>% 
  dplyr::rename(Skin_Interactions = n)

# Merge datasets by the 'source' (27 levels - celltypes) column
combined_data.diff <- full_join(df.t, df.s, by = "source")

# Remove NA values because T naive CD4 in Skin_Interactions = NA
combined_data.diff$Tumor_Interactions[
  is.na(combined_data.diff$Tumor_Interactions)
  ] <- 0
combined_data.diff$Skin_Interactions[
  is.na(combined_data.diff$Skin_Interactions)
  ] <- 0

# Compute the difference for each source: skin - SCC
combined_data.diff$Interaction_Difference <- 
  combined_data.diff$Tumor_Interactions - combined_data.diff$Skin_Interactions

# Display the table (screenshot saved)
print(combined_data.diff, n = 27)# Display the table (screenshot saved)
## # A tibble: 27 × 4
##    source            Tumor_Interactions Skin_Interactions Interaction_Difference
##    <fct>                          <dbl>             <dbl>                  <dbl>
##  1 B cell                           363               456                    -93
##  2 Endothel                         884               638                    246
##  3 Endothel_vasc._31               1071               860                    211
##  4 Erythrocyte                       88                92                     -4
##  5 Fibroblast_18                   1152              1100                     52
##  6 Fibroblast_20                    993               813                    180
##  7 Fibroblast_25                    551               458                     93
##  8 Fibroblast_32                   1299              1002                    297
##  9 Fibroblast_36                   1116              1241                   -125
## 10 T gd                             260               300                    -40
## 11 Keratinocyte_26                  551               615                    -64
## 12 Mast_27                          154               127                     27
## 13 Monocyte                         451               352                     99
## 14 Monocyte_23                      276               175                    101
## 15 Neurons_47                        25               174                   -149
## 16 Neutrophil                       105               157                    -52
## 17 NK                               239               346                   -107
## 18 NK T like                        293               242                     51
## 19 Plasma_15                        301               329                    -28
## 20 Plasma_35                         62               165                   -103
## 21 Plasma_37                        284               313                    -29
## 22 Schwann_43                       813               803                     10
## 23 T cytotox. CD8                   266               329                    -63
## 24 T fh                             536               504                     32
## 25 T mem 1                          211               266                    -55
## 26 T mem 2                          250               309                    -59
## 27 T reg CD4                        230               289                    -59

Scatter plot source

scatter_plot <- ggplot(
  combined_data.diff, 
  aes(x = Tumor_Interactions, 
      y = Skin_Interactions, 
      label = source)) +
  geom_point(
    aes(color = source), size = 3
    ) +
  geom_text(
    aes(label = source), size = 3
    ) +
  geom_smooth(
    method = "lm",
    se = TRUE
    ) +
  labs(
    title = "Number of Interactions per source Cell", 
    x = "SCC Interactions", 
    y = "Skin Interactions"
    ) +
  theme(legend.position = "none")+
    theme_minimal() 

print(scatter_plot)
## `geom_smooth()` using formula = 'y ~ x'
## Warning: The following aesthetics were dropped during statistical transformation: label.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?

ggsave("~/rocker/RDEB/thesis/scatter_plot_source.png", 
       plot = scatter_plot, 
       width = 10, 
       height = 8, 
       dpi = 300)
## `geom_smooth()` using formula = 'y ~ x'
## Warning: The following aesthetics were dropped during statistical transformation: label.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?

Number of interactions per target cell (receptor) in SCC - skin

# Compute interaction counts for each dataset
df.t <- cellchat.t %>%
  subsetCommunication(thresh = NA) %>% 
  filter(source != naive_CD4_identifier & target != naive_CD4_identifier) %>% 
  dplyr::as_tibble() %>% 
  dplyr::count(target) %>% 
  dplyr::rename(Tumor_Interactions = n)
df.s <- cellchat.s %>% 
  subsetCommunication(thresh = NA) %>% 
  dplyr::as_tibble() %>% 
  dplyr::count(target) %>% 
  dplyr::rename(Skin_Interactions = n)

# Merge datasets by the 'target' (27 levels - celltypes) column
combined_data.diff <- full_join(
  df.t,
  df.s, 
  by = "target")

# Remove NA values because T naive CD4 in Skin_Interactions = NA
combined_data.diff$Tumor_Interactions[
  is.na(combined_data.diff$Tumor_Interactions)
  ] <- 0
combined_data.diff$Skin_Interactions[
  is.na(combined_data.diff$Skin_Interactions)
  ] <- 0

# Compute the difference for each target: SCC - skin
combined_data.diff$Interaction_Difference <- 
  combined_data.diff$Tumor_Interactions  - combined_data.diff$Skin_Interactions
print (combined_data.diff, n = 27) # Display the table (screenshot saved)
## # A tibble: 26 × 4
##    target            Tumor_Interactions Skin_Interactions Interaction_Difference
##    <fct>                          <dbl>             <dbl>                  <dbl>
##  1 B cell                           293               333                    -40
##  2 Endothel                         581               291                    290
##  3 Endothel_vasc._31                915               929                    -14
##  4 Fibroblast_18                    764               659                    105
##  5 Fibroblast_20                    561               428                    133
##  6 Fibroblast_25                    188               152                     36
##  7 Fibroblast_32                    852               575                    277
##  8 Fibroblast_36                    709               976                   -267
##  9 T gd                             324               505                   -181
## 10 Keratinocyte_26                  611               705                    -94
## 11 Mast_27                          300               183                    117
## 12 Monocyte                         827               569                    258
## 13 Monocyte_23                      193               196                     -3
## 14 Neurons_47                        25               162                   -137
## 15 Neutrophil                       275               257                     18
## 16 NK                               539               691                   -152
## 17 NK T like                        235               282                    -47
## 18 Plasma_15                        511               542                    -31
## 19 Plasma_35                        283               168                    115
## 20 Plasma_37                        492               535                    -43
## 21 Schwann_43                       686               595                     91
## 22 T cytotox. CD8                   596               588                      8
## 23 T fh                             748               867                   -119
## 24 T mem 1                          416               339                     77
## 25 T mem 2                          442               448                     -6
## 26 T reg CD4                        458               480                    -22

Scatter plot target

scatter_plot <- ggplot(combined_data.diff, 
                       aes(
                         x = Tumor_Interactions, 
                         y = Skin_Interactions, 
                         label = target)
                       ) + 
  geom_point(aes(color = target), size = 3) +
  geom_text(aes(label = target), size = 3) +
  geom_smooth(method = "lm",se = TRUE) +
  labs(
    title = "Number of Interactions per target Cell", 
       x = "SCC Interactions", 
       y = "Skin Interactions"
    ) +
  theme(legend.position = "none")+
    theme_minimal() 

print(scatter_plot)
## `geom_smooth()` using formula = 'y ~ x'
## Warning: The following aesthetics were dropped during statistical transformation: label.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?

ggsave("~/rocker/RDEB/thesis/scatter_plot_target.png", 
       plot = scatter_plot, 
       width = 10, 
       height = 8, 
       dpi = 300)
## `geom_smooth()` using formula = 'y ~ x'
## Warning: The following aesthetics were dropped during statistical transformation: label.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?

Plotting top 10 interactions with biggest differences in SCC - skin

# Combining data SCC and skin 
df.t <- cellchat.t %>%
  subsetCommunication(thresh = NA) %>% 
  filter(source != naive_CD4_identifier & target != naive_CD4_identifier) %>% 
  dplyr::as_tibble() %>% 
  dplyr::group_by(source, target) %>%
  dplyr::summarise(Tumor_Interactions = n())
## `summarise()` has grouped output by 'source'. You can override using the
## `.groups` argument.
df.s <- cellchat.s %>% 
  subsetCommunication(thresh = NA) %>% 
  dplyr::as_tibble() %>% 
  dplyr::group_by(source, target) %>% 
  dplyr::summarise(Skin_Interactions = n())
## `summarise()` has grouped output by 'source'. You can override using the
## `.groups` argument.
# Merge datasets by the 'source' and 'target'
combined_data.diff <- full_join(
  df.t, 
  df.s, 
  by = c("source", "target")
  )

# Replace NAs with 0
combined_data.diff$Tumor_Interactions[
  is.na(combined_data.diff$Tumor_Interactions)
  ] <- 0
combined_data.diff$Skin_Interactions[
  is.na(combined_data.diff$Skin_Interactions)
  ] <- 0

# Compute the difference for each source-target pair: skin - SCC
combined_data.diff$Interaction_Difference <- 
  combined_data.diff$Tumor_Interactions  - combined_data.diff$Skin_Interactions

# Filter to get the top 10 interactions by absolute difference
top_10_diff <- combined_data.diff %>%
  dplyr::ungroup() %>% # Calculate differences without grouping by 'source'
  dplyr::arrange(-abs(Interaction_Difference)) %>%
  dplyr::slice_head(n = 10)

print(top_10_diff)
## # A tibble: 10 × 5
##    source     target Tumor_Interactions Skin_Interactions Interaction_Difference
##    <fct>      <fct>               <dbl>             <dbl>                  <dbl>
##  1 Fibroblas… Fibro…                 88                47                     41
##  2 Fibroblas… Fibro…                 71               111                    -40
##  3 Fibroblas… Endot…                 59                21                     38
##  4 Endothel_… Fibro…                 80                43                     37
##  5 Fibroblas… Monoc…                 79                43                     36
##  6 Fibroblas… Endot…                 49                16                     33
##  7 Fibroblas… Fibro…                 73                42                     31
##  8 Fibroblas… Endot…                 53                23                     30
##  9 Fibroblas… Fibro…                 63                93                    -30
## 10 Endothel   Endot…                 44                15                     29
# Plot top 10 interactions with biggest differences 
difference_plot <- ggplot(
  top_10_diff, 
  aes(
    x = paste(source, target, sep = "-"), 
    y = Interaction_Difference,
    fill = Interaction_Difference > 0)
  ) +
  geom_bar(
    stat = "identity",
    position = "dodge"
    ) +
  scale_fill_manual(
    values = c(
      "TRUE" = rgb(178/255, 24/255, 43/255),
      "FALSE" = rgb(33/255, 102/255, 172/255)
      ),
                    labels = c(
                      "TRUE" = "SCC",
                      "FALSE" = "Skin")
    ) +
  theme_minimal() +
  labs(
    title = "Top 10 Differences in Interactions (SCC - Skin)", 
    y = "Difference in Interactions", 
    x = "Interaction (Source-target)") +
  theme(axis.text.x = element_text(
    angle = 90, 
    hjust = 1)
    )

print(difference_plot)

ggsave("~/rocker/RDEB/thesis/Top_10_Differences_in_Interactions.png", 
       plot = difference_plot, 
       width = 10, 
       height = 8, 
       dpi = 300)

Function to process interactions between sorce and target celltypes

plot_interaction <- function(
    df, 
    source_value, 
    target_value) {
  df_filtered <- df %>%
    filter(source == source_value & target == target_value) %>%
    slice_max(
      order_by = abs(prob.delta), 
      n = 40) %>%
    select(-c(pval.t, pval.s))

  # Create a label from the source and target values
  interaction_label <- paste(
    source_value, 
    target_value, 
    sep = " to ")

  # Pivot and plot using the new label
  df_filtered %>%
    pivot_longer(cols = c("prob.s", "prob.t"), 
                 names_to = "variable", 
                 values_to = "value") %>%
    ggplot(aes(
      x = interaction_name_2, 
      y = value, 
      fill = variable)
      ) +
    geom_col(position = "dodge") +
    scale_fill_manual(
      values = c(
      "prob.s" = rgb(33/255, 102/255, 172/255), 
      "prob.t" = rgb(178/255, 24/255, 43/255)
      )
      ) +
    labs(
      x = interaction_label, 
      y = "Probability Delta", 
      fill = "Probability"
      ) +
    theme(axis.text.x = element_text(
      angle = 90, 
      hjust = 1, 
      vjust = 0.5)
      )
}

Interaction based on cell types

# Now, let's loop over these top 10 interactions and create the desired plots.
for (i in 1:nrow(top_10_diff)) {
  current_source <- top_10_diff$source[i]
  current_target <- top_10_diff$target[i]

  # Filter the merged_data for the current pair.
  current_data <- merged_data %>%
    filter(source == current_source, 
           target == current_target)

  # Plot
  p <- ggplot(
    current_data, 
    aes(
      x = ligand, 
      y = receptor, 
      fill = prob.delta)
    ) +
    geom_tile() +
    scale_fill_gradient2(
      low = rgb(33/255, 102/255, 172/255), 
      high = rgb(178/255, 24/255, 43/255), 
      mid = "grey", 
      midpoint = 0,
      limits = c(min(current_data$prob.delta, na.rm = TRUE), 
                 max(current_data$prob.delta, na.rm = TRUE)),
      name = "Prob Delta") +
    labs(title = paste("Ligand-Receptor Interactions for",
                       current_source,
                       "to",
                       current_target),
         x = "Ligand",
         y = "Receptor"
         ) +
    theme_minimal() +
    theme(axis.text.x = element_text(
      angle = 90, 
      vjust = 0.5
      ),
          axis.text.y = element_text(hjust = 1))
   
  print(p)

  # Save the plot
  file_name <- paste0("~/rocker/RDEB/thesis/interaction_plots/",
                      current_source,
                      "_to_",
                      current_target, 
                      ".pdf"
                      )
  ggsave(
    file_name,
    plot = p,
    width = 10,
    height = 10
    )
  
  # Extracting the relevant interactions from merged_data for the current interaction pair
  filtered_data <- current_data %>%
    distinct(pathway_name)  # Getting unique pathway names involved in these interactions

  # Print the pathways involved in the current interaction pair
  cat("Pathways for interaction", current_source, "to", current_target, ":\n")
  print(filtered_data)

  # Check if these pathways are in the provided pathways lists
  pathways_involved_t <- filtered_data$pathway_name %in% pathways.show.t
  pathways_involved_s <- filtered_data$pathway_name %in% pathways.show.s

  # Print pathways involved both in tumor and skin for the current interaction pair
  cat("Pathways in Tumor:\n")
  print(filtered_data$pathway_name[pathways_involved_t])
  cat("Pathways in Skin:\n")
  print(filtered_data$pathway_name[pathways_involved_s])
}

## Pathways for interaction 8 to 8 :
##    pathway_name
## 1      COLLAGEN
## 2          NEGR
## 3            MK
## 4       LAMININ
## 5      TENASCIN
## 6         SEMA4
## 7           FN1
## 8      VISFATIN
## 9           FGF
## 10         THBS
## 11        ncWNT
## 12       ANGPTL
## 13         TGFb
## 14          GAS
## 15         CD99
## 16        PTPRM
## 17          JAM
## 18         CXCL
## 19    PERIOSTIN
## 20        SEMA3
## 21         PROS
## 22         CADM
## 23         PDGF
## 24         CNTN
## 25          PTN
## 26       NECTIN
## 27        TWEAK
## 28          BMP
## 29          MIF
## 30          MPZ
## 31          IGF
## 32          WNT
## Pathways in Tumor:
##  [1] "COLLAGEN"  "NEGR"      "MK"        "LAMININ"   "TENASCIN"  "SEMA4"    
##  [7] "FN1"       "VISFATIN"  "FGF"       "THBS"      "ncWNT"     "ANGPTL"   
## [13] "TGFb"      "GAS"       "CD99"      "PTPRM"     "JAM"       "CXCL"     
## [19] "PERIOSTIN" "SEMA3"     "PROS"      "CADM"      "PDGF"      "CNTN"     
## [25] "PTN"       "NECTIN"    "TWEAK"     "BMP"       "MIF"       "MPZ"      
## [31] "IGF"       "WNT"      
## Pathways in Skin:
##  [1] "COLLAGEN"  "NEGR"      "MK"        "LAMININ"   "TENASCIN"  "SEMA4"    
##  [7] "FN1"       "VISFATIN"  "FGF"       "THBS"      "ncWNT"     "ANGPTL"   
## [13] "TGFb"      "GAS"       "CD99"      "PTPRM"     "JAM"       "CXCL"     
## [19] "PERIOSTIN" "SEMA3"     "PROS"      "CADM"      "PDGF"      "PTN"      
## [25] "NECTIN"    "TWEAK"     "BMP"       "MIF"       "MPZ"       "IGF"      
## [31] "WNT"

## Pathways for interaction 9 to 9 :
##    pathway_name
## 1      COLLAGEN
## 2        ANGPTL
## 3       LAMININ
## 4            MK
## 5          THBS
## 6           MPZ
## 7      VISFATIN
## 8           JAM
## 9          NEGR
## 10          IL6
## 11        SEMA3
## 12          FN1
## 13        SEMA4
## 14          FGF
## 15          GAS
## 16     TENASCIN
## 17       ADGRE5
## 18         PROS
## 19         CXCL
## 20        NOTCH
## 21         CD46
## 22       NECTIN
## 23          PTN
## 24        TWEAK
## 25         CD99
## 26    PERIOSTIN
## 27         HSPG
## 28        PTPRM
## 29         EPHA
## 30         TGFb
## 31         PDGF
## 32         EPHB
## 33         CADM
## 34          MIF
## 35          IGF
## 36          WNT
## Pathways in Tumor:
##  [1] "COLLAGEN"  "ANGPTL"    "LAMININ"   "MK"        "THBS"      "MPZ"      
##  [7] "VISFATIN"  "JAM"       "NEGR"      "IL6"       "SEMA3"     "FN1"      
## [13] "SEMA4"     "FGF"       "GAS"       "TENASCIN"  "ADGRE5"    "PROS"     
## [19] "CXCL"      "NOTCH"     "CD46"      "NECTIN"    "PTN"       "TWEAK"    
## [25] "CD99"      "PERIOSTIN" "HSPG"      "PTPRM"     "EPHA"      "TGFb"     
## [31] "PDGF"      "EPHB"      "CADM"      "MIF"       "IGF"       "WNT"      
## Pathways in Skin:
##  [1] "COLLAGEN"  "ANGPTL"    "LAMININ"   "MK"        "THBS"      "MPZ"      
##  [7] "VISFATIN"  "JAM"       "NEGR"      "IL6"       "SEMA3"     "FN1"      
## [13] "SEMA4"     "FGF"       "GAS"       "TENASCIN"  "ADGRE5"    "PROS"     
## [19] "CXCL"      "NOTCH"     "CD46"      "NECTIN"    "PTN"       "TWEAK"    
## [25] "CD99"      "PERIOSTIN" "HSPG"      "PTPRM"     "EPHA"      "TGFb"     
## [31] "PDGF"      "EPHB"      "CADM"      "MIF"       "IGF"       "WNT"

## Pathways for interaction 8 to 2 :
##    pathway_name
## 1      COLLAGEN
## 2       LAMININ
## 3            MK
## 4      VISFATIN
## 5           MIF
## 6           FN1
## 7          CXCL
## 8         SEMA4
## 9         CALCR
## 10       ANGPTL
## 11         CD46
## 12          CCL
## 13          PTN
## 14        ncWNT
## 15         VEGF
## 16        PTPRM
## 17         CD99
## 18        SEMA3
## 19       NECTIN
## 20          APJ
## 21         PDGF
## 22          APP
## 23          IGF
## Pathways in Tumor:
##  [1] "COLLAGEN" "LAMININ"  "MK"       "VISFATIN" "MIF"      "FN1"     
##  [7] "CXCL"     "SEMA4"    "CALCR"    "ANGPTL"   "CD46"     "CCL"     
## [13] "PTN"      "ncWNT"    "VEGF"     "PTPRM"    "CD99"     "SEMA3"   
## [19] "NECTIN"   "APJ"      "PDGF"     "APP"      "IGF"     
## Pathways in Skin:
##  [1] "COLLAGEN" "LAMININ"  "MK"       "VISFATIN" "MIF"      "FN1"     
##  [7] "CXCL"     "SEMA4"    "CALCR"    "ANGPTL"   "CD46"     "CCL"     
## [13] "PTN"      "ncWNT"    "VEGF"     "PTPRM"    "CD99"     "SEMA3"   
## [19] "NECTIN"   "PDGF"     "APP"      "IGF"

## Pathways for interaction 3 to 8 :
##    pathway_name
## 1      COLLAGEN
## 2          SELE
## 3       LAMININ
## 4      VISFATIN
## 5           JAM
## 6         ANGPT
## 7          THBS
## 8      GALECTIN
## 9         SEMA4
## 10         CD99
## 11        SEMA6
## 12        NOTCH
## 13        PTPRM
## 14          FN1
## 15          EDN
## 16     TENASCIN
## 17         TGFb
## 18         PROS
## 19    PERIOSTIN
## 20        SEMA3
## 21         VCAM
## 22         CXCL
## 23          BMP
## 24          MIF
## 25          GAS
## 26          MPZ
## 27          EGF
## 28         PDGF
## 29          WNT
## Pathways in Tumor:
##  [1] "COLLAGEN"  "SELE"      "LAMININ"   "VISFATIN"  "JAM"       "ANGPT"    
##  [7] "THBS"      "GALECTIN"  "SEMA4"     "CD99"      "SEMA6"     "NOTCH"    
## [13] "PTPRM"     "FN1"       "EDN"       "TENASCIN"  "TGFb"      "PROS"     
## [19] "PERIOSTIN" "SEMA3"     "VCAM"      "CXCL"      "BMP"       "MIF"      
## [25] "GAS"       "MPZ"       "EGF"       "PDGF"      "WNT"      
## Pathways in Skin:
##  [1] "COLLAGEN"  "SELE"      "LAMININ"   "VISFATIN"  "JAM"       "ANGPT"    
##  [7] "THBS"      "SEMA4"     "CD99"      "SEMA6"     "NOTCH"     "PTPRM"    
## [13] "FN1"       "EDN"       "TENASCIN"  "TGFb"      "PROS"      "PERIOSTIN"
## [19] "SEMA3"     "VCAM"      "CXCL"      "BMP"       "MIF"       "GAS"      
## [25] "MPZ"       "EGF"       "PDGF"      "WNT"

## Pathways for interaction 8 to 13 :
##    pathway_name
## 1           FN1
## 2      COLLAGEN
## 3          CD99
## 4       LAMININ
## 5    COMPLEMENT
## 6      TENASCIN
## 7            MK
## 8          THY1
## 9           MIF
## 10         THBS
## 11         CXCL
## 12      ANNEXIN
## 13          IL6
## 14          FGF
## 15       ANGPTL
## 16          GAS
## 17          CSF
## 18        MHC-I
## 19        SEMA3
## 20        SEMA4
## 21       MHC-II
## 22          JAM
## 23          MPZ
## 24         IL16
## 25         ICAM
## 26         PROS
## 27       NECTIN
## 28          PTN
## 29          APP
## 30         TGFb
## 31     VISFATIN
## 32         VEGF
## Pathways in Tumor:
##  [1] "FN1"        "COLLAGEN"   "CD99"       "LAMININ"    "COMPLEMENT"
##  [6] "TENASCIN"   "MK"         "THY1"       "MIF"        "THBS"      
## [11] "CXCL"       "ANNEXIN"    "IL6"        "FGF"        "ANGPTL"    
## [16] "GAS"        "CSF"        "MHC-I"      "SEMA3"      "SEMA4"     
## [21] "MHC-II"     "JAM"        "MPZ"        "IL16"       "ICAM"      
## [26] "PROS"       "NECTIN"     "PTN"        "APP"        "TGFb"      
## [31] "VISFATIN"   "VEGF"      
## Pathways in Skin:
##  [1] "FN1"        "COLLAGEN"   "CD99"       "LAMININ"    "COMPLEMENT"
##  [6] "TENASCIN"   "MK"         "THY1"       "MIF"        "THBS"      
## [11] "CXCL"       "ANNEXIN"    "IL6"        "FGF"        "ANGPTL"    
## [16] "GAS"        "CSF"        "MHC-I"      "SEMA3"      "SEMA4"     
## [21] "MHC-II"     "JAM"        "MPZ"        "IL16"       "ICAM"      
## [26] "PROS"       "NECTIN"     "PTN"        "APP"        "TGFb"      
## [31] "VISFATIN"   "VEGF"

## Pathways for interaction 6 to 2 :
##    pathway_name
## 1      COLLAGEN
## 2       LAMININ
## 3          CD99
## 4      VISFATIN
## 5           MIF
## 6           FN1
## 7          VEGF
## 8          CD46
## 9         SEMA4
## 10       ADGRE5
## 11          CCL
## 12         ESAM
## 13         PDGF
## 14        ANGPT
## 15          APP
## 16        PTPRM
## Pathways in Tumor:
##  [1] "COLLAGEN" "LAMININ"  "CD99"     "VISFATIN" "MIF"      "FN1"     
##  [7] "VEGF"     "CD46"     "SEMA4"    "ADGRE5"   "CCL"      "ESAM"    
## [13] "PDGF"     "ANGPT"    "APP"      "PTPRM"   
## Pathways in Skin:
##  [1] "COLLAGEN" "LAMININ"  "CD99"     "VISFATIN" "MIF"      "FN1"     
##  [7] "VEGF"     "CD46"     "SEMA4"    "ADGRE5"   "CCL"      "ESAM"    
## [13] "PDGF"     "ANGPT"    "APP"      "PTPRM"

## Pathways for interaction 8 to 6 :
##    pathway_name
## 1       LAMININ
## 2            MK
## 3          CD99
## 4          CD46
## 5      COLLAGEN
## 6           GAS
## 7     PERIOSTIN
## 8          THBS
## 9      VISFATIN
## 10        ncWNT
## 11         NEGR
## 12        CALCR
## 13          MPZ
## 14         HSPG
## 15          JAM
## 16          FN1
## 17          PTN
## 18         PROS
## 19       NECTIN
## 20         PDGF
## 21          CSF
## 22        PTPRM
## 23          BMP
## 24         EPHA
## 25          IGF
## Pathways in Tumor:
##  [1] "LAMININ"   "MK"        "CD99"      "CD46"      "COLLAGEN"  "GAS"      
##  [7] "PERIOSTIN" "THBS"      "VISFATIN"  "ncWNT"     "NEGR"      "CALCR"    
## [13] "MPZ"       "HSPG"      "JAM"       "FN1"       "PTN"       "PROS"     
## [19] "NECTIN"    "PDGF"      "CSF"       "PTPRM"     "BMP"       "EPHA"     
## [25] "IGF"      
## Pathways in Skin:
##  [1] "LAMININ"   "MK"        "CD99"      "CD46"      "COLLAGEN"  "GAS"      
##  [7] "PERIOSTIN" "THBS"      "VISFATIN"  "ncWNT"     "NEGR"      "CALCR"    
## [13] "MPZ"       "HSPG"      "JAM"       "FN1"       "PTN"       "PROS"     
## [19] "NECTIN"    "PDGF"      "CSF"       "PTPRM"     "BMP"       "EPHA"     
## [25] "IGF"

## Pathways for interaction 5 to 2 :
##    pathway_name
## 1      COLLAGEN
## 2       LAMININ
## 3      VISFATIN
## 4           FN1
## 5         ncWNT
## 6         SEMA4
## 7          CXCL
## 8          VEGF
## 9        ANGPTL
## 10          MIF
## 11          APP
## 12         CD46
## 13        SEMA3
## 14          PTN
## 15           MK
## 16          CCL
## 17       NECTIN
## 18        PTPRM
## 19          APJ
## 20        CALCR
## 21         PDGF
## 22         CD99
## 23          IGF
## Pathways in Tumor:
##  [1] "COLLAGEN" "LAMININ"  "VISFATIN" "FN1"      "ncWNT"    "SEMA4"   
##  [7] "CXCL"     "VEGF"     "ANGPTL"   "MIF"      "APP"      "CD46"    
## [13] "SEMA3"    "PTN"      "MK"       "CCL"      "NECTIN"   "PTPRM"   
## [19] "APJ"      "CALCR"    "PDGF"     "CD99"     "IGF"     
## Pathways in Skin:
##  [1] "COLLAGEN" "LAMININ"  "VISFATIN" "FN1"      "ncWNT"    "SEMA4"   
##  [7] "CXCL"     "VEGF"     "ANGPTL"   "MIF"      "APP"      "CD46"    
## [13] "SEMA3"    "PTN"      "MK"       "CCL"      "NECTIN"   "PTPRM"   
## [19] "CALCR"    "PDGF"     "CD99"     "IGF"

## Pathways for interaction 5 to 9 :
##    pathway_name
## 1      COLLAGEN
## 2          THBS
## 3       LAMININ
## 4        ANGPTL
## 5           FGF
## 6         ncWNT
## 7      VISFATIN
## 8         SEMA4
## 9           IL6
## 10         NEGR
## 11        SEMA3
## 12          GAS
## 13          MPZ
## 14          FN1
## 15         CADM
## 16     TENASCIN
## 17          PTN
## 18         TGFb
## 19          JAM
## 20           MK
## 21         PROS
## 22        PTPRM
## 23         EPHA
## 24       NECTIN
## 25         CD46
## 26         PDGF
## 27         HSPG
## 28         CD99
## 29          MIF
## 30    PERIOSTIN
## 31         CXCL
## 32          IGF
## Pathways in Tumor:
##  [1] "COLLAGEN"  "THBS"      "LAMININ"   "ANGPTL"    "FGF"       "ncWNT"    
##  [7] "VISFATIN"  "SEMA4"     "IL6"       "NEGR"      "SEMA3"     "GAS"      
## [13] "MPZ"       "FN1"       "CADM"      "TENASCIN"  "PTN"       "TGFb"     
## [19] "JAM"       "MK"        "PROS"      "PTPRM"     "EPHA"      "NECTIN"   
## [25] "CD46"      "PDGF"      "HSPG"      "CD99"      "MIF"       "PERIOSTIN"
## [31] "CXCL"      "IGF"      
## Pathways in Skin:
##  [1] "COLLAGEN"  "THBS"      "LAMININ"   "ANGPTL"    "FGF"       "ncWNT"    
##  [7] "VISFATIN"  "SEMA4"     "IL6"       "NEGR"      "SEMA3"     "GAS"      
## [13] "MPZ"       "FN1"       "CADM"      "TENASCIN"  "PTN"       "TGFb"     
## [19] "JAM"       "MK"        "PROS"      "PTPRM"     "EPHA"      "NECTIN"   
## [25] "CD46"      "PDGF"      "HSPG"      "CD99"      "MIF"       "PERIOSTIN"
## [31] "CXCL"      "IGF"

## Pathways for interaction 2 to 2 :
##    pathway_name
## 1      COLLAGEN
## 2           MIF
## 3       LAMININ
## 4      VISFATIN
## 5          CD99
## 6         SEMA4
## 7           FN1
## 8        PECAM1
## 9          CXCL
## 10         CD46
## 11          CCL
## 12          APP
## 13         ESAM
## 14        PTPRM
## 15        ANGPT
## 16         CDH5
## Pathways in Tumor:
##  [1] "COLLAGEN" "MIF"      "LAMININ"  "VISFATIN" "CD99"     "SEMA4"   
##  [7] "FN1"      "PECAM1"   "CXCL"     "CD46"     "CCL"      "APP"     
## [13] "ESAM"     "PTPRM"    "ANGPT"    "CDH5"    
## Pathways in Skin:
##  [1] "COLLAGEN" "MIF"      "LAMININ"  "VISFATIN" "CD99"     "SEMA4"   
##  [7] "FN1"      "PECAM1"   "CXCL"     "CD46"     "CCL"      "APP"     
## [13] "ESAM"     "PTPRM"    "ANGPT"    "CDH5"
# List of interactions
interactions <- list(
  "Fibroblast_32 to Fibroblast_32" = list(
    "tumor" = c("COLLAGEN", "NEGR", "MK", "LAMININ", "TENASCIN", "SEMA4", "FN1", "VISFATIN", "FGF", "THBS", "ncWNT", "ANGPTL", "TGFb", "GAS", "CD99", "PTPRM", "JAM", "CXCL", "PERIOSTIN", "SEMA3", "PROS", "CADM", "PDGF", "CNTN", "PTN", "NECTIN", "TWEAK", "BMP", "MIF", "MPZ", "IGF", "WNT"),
    "skin" = c("COLLAGEN", "NEGR", "MK", "LAMININ", "TENASCIN", "SEMA4", "FN1", "VISFATIN", "FGF", "THBS", "ncWNT", "ANGPTL", "TGFb", "GAS", "CD99", "PTPRM", "JAM", "CXCL", "PERIOSTIN", "SEMA3", "PROS", "CADM", "PDGF", "PTN", "NECTIN", "TWEAK", "BMP", "MIF", "MPZ", "IGF", "WNT")
  ),
  "Fibroblast_36 to Fibroblast_36" = list(
    "tumor" = c("COLLAGEN", "ANGPTL", "LAMININ", "MK", "THBS", "MPZ", "VISFATIN", "JAM", "NEGR", "IL6", "SEMA3", "FN1", "SEMA4", "FGF", "GAS", "TENASCIN", "ADGRE5", "PROS", "CXCL", "NOTCH", "CD46", "NECTIN", "PTN", "TWEAK", "CD99", "PERIOSTIN", "HSPG", "PTPRM", "EPHA", "TGFb", "PDGF", "EPHB", "CADM", "MIF", "IGF", "WNT"),
    "skin" = c("COLLAGEN", "ANGPTL", "LAMININ", "MK", "THBS", "MPZ", "VISFATIN", "JAM", "NEGR", "IL6", "SEMA3", "FN1", "SEMA4", "FGF", "GAS", "TENASCIN", "ADGRE5", "PROS", "CXCL", "NOTCH", "CD46", "NECTIN", "PTN", "TWEAK", "CD99", "PERIOSTIN", "HSPG", "PTPRM", "EPHA", "TGFb", "PDGF", "EPHB", "CADM", "MIF", "IGF", "WNT")
  ),
  "Fibroblast_32 to Endothel" = list(
    "tumor" = c("COLLAGEN", "LAMININ", "MK", "VISFATIN", "MIF", "FN1", "CXCL", "SEMA4", "CALCR", "ANGPTL", "CD46", "CCL", "PTN", "ncWNT", "VEGF", "PTPRM", "CD99", "SEMA3", "NECTIN", "APJ", "PDGF", "APP", "IGF"),
    "skin" = c("COLLAGEN", "LAMININ", "MK", "VISFATIN", "MIF", "FN1", "CXCL", "SEMA4", "CALCR", "ANGPTL", "CD46", "CCL", "PTN", "ncWNT", "VEGF", "PTPRM", "CD99", "SEMA3", "NECTIN", "PDGF", "APP", "IGF")
  ),
  "Endothel_vasc._31 to Fibroblast_32" = list(
    "tumor" = c("COLLAGEN", "SELE", "LAMININ", "VISFATIN", "JAM", "ANGPT", "THBS", "GALECTIN", "SEMA4", "CD99", "SEMA6", "NOTCH", "PTPRM", "FN1", "EDN", "TENASCIN", "TGFb", "PROS", "PERIOSTIN", "SEMA3", "VCAM", "CXCL", "BMP", "MIF", "GAS", "MPZ", "EGF", "PDGF", "WNT"),
    "skin" = c("COLLAGEN", "SELE", "LAMININ", "VISFATIN", "JAM", "ANGPT", "THBS", "SEMA4", "CD99", "SEMA6", "NOTCH", "PTPRM", "FN1", "EDN", "TENASCIN", "TGFb", "PROS", "PERIOSTIN", "SEMA3", "VCAM", "CXCL", "BMP", "MIF", "GAS", "MPZ", "EGF", "PDGF", "WNT") 
  ),
  "Fibroblast_32 to Monocyte" = list(
    "tumor" = c("FN1", "COLLAGEN", "CD99", "LAMININ", "COMPLEMENT", "TENASCIN", "MK", "THY1", "MIF", "THBS", "CXCL", "ANNEXIN", "IL6", "FGF", "ANGPTL", "GAS", "CSF", "MHC-I", "SEMA3", "SEMA4", "MHC-II", "JAM", "MPZ", "IL16", "ICAM", "PROS", "NECTIN", "PTN", "APP", "TGFb", "VISFATIN", "VEGF"),
    "skin" = c("FN1", "COLLAGEN", "CD99", "LAMININ", "COMPLEMENT", "TENASCIN", "MK", "THY1", "MIF", "THBS", "CXCL", "ANNEXIN", "IL6", "FGF", "ANGPTL", "GAS", "CSF", "MHC-I", "SEMA3", "SEMA4", "MHC-II", "JAM", "MPZ", "IL16", "ICAM", "PROS", "NECTIN", "PTN", "APP", "TGFb", "VISFATIN", "VEGF")
  ),
  "Fibroblast_20 to Endothel" = list(
    "tumor" = c("COLLAGEN", "LAMININ", "CD99", "VISFATIN", "MIF", "FN1", "VEGF", "CD46", "SEMA4", "ADGRE5", "CCL", "ESAM", "PDGF", "ANGPT", "APP", "PTPRM"),
    "skin" = c("COLLAGEN", "LAMININ", "CD99", "VISFATIN", "MIF", "FN1", "VEGF", "CD46", "SEMA4", "ADGRE5", "CCL", "ESAM", "PDGF", "ANGPT", "APP", "PTPRM")
  ),
  "Fibroblast_32 to Fibroblast_20" = list(
    "tumor" = c("LAMININ", "MK", "CD99", "CD46", "COLLAGEN", "GAS", "PERIOSTIN", "THBS", "VISFATIN", "ncWNT", "NEGR", "CALCR", "MPZ", "HSPG", "JAM", "FN1", "PTN", "PROS", "NECTIN", "PDGF", "CSF", "PTPRM", "BMP", "EPHA", "IGF"),
    "skin" = c("LAMININ", "MK", "CD99", "CD46", "COLLAGEN", "GAS", "PERIOSTIN", "THBS", "VISFATIN", "ncWNT", "NEGR", "CALCR", "MPZ", "HSPG", "JAM", "FN1", "PTN", "PROS", "NECTIN", "PDGF", "CSF", "PTPRM", "BMP", "EPHA", "IGF")
  ),
  "Fibroblast_18 to Endothel" = list(
    "tumor" = c("COLLAGEN", "LAMININ", "VISFATIN", "FN1", "ncWNT", "SEMA4", "CXCL", "VEGF", "ANGPTL", "MIF", "APP", "CD46", "SEMA3", "PTN", "MK", "CCL", "NECTIN", "PTPRM", "APJ", "CALCR", "PDGF", "CD99", "IGF"),
    "skin" = c("COLLAGEN", "LAMININ", "VISFATIN", "FN1", "ncWNT", "SEMA4", "CXCL", "VEGF", "ANGPTL", "MIF", "APP", "CD46", "SEMA3", "PTN", "MK", "CCL", "NECTIN", "PTPRM", "CALCR", "PDGF", "CD99", "IGF")
  ),
  "Fibroblast_18 to Fibroblast_36" = list(
    "tumor" = c("COLLAGEN", "THBS", "LAMININ", "ANGPTL", "FGF", "ncWNT", "VISFATIN", "SEMA4", "IL6", "NEGR", "SEMA3", "GAS", "MPZ", "FN1", "CADM", "TENASCIN", "PTN", "TGFb", "JAM", "MK", "PROS", "PTPRM", "EPHA", "NECTIN", "CD46", "PDGF", "HSPG", "CD99", "MIF", "PERIOSTIN", "CXCL", "IGF"),
    "skin" = c("COLLAGEN", "THBS", "LAMININ", "ANGPTL", "FGF", "ncWNT", "VISFATIN", "SEMA4", "IL6", "NEGR", "SEMA3", "GAS", "MPZ", "FN1", "CADM", "TENASCIN", "PTN", "TGFb", "JAM", "MK", "PROS", "PTPRM", "EPHA", "NECTIN", "CD46", "PDGF", "HSPG", "CD99", "MIF", "PERIOSTIN", "CXCL", "IGF")
  ),
  "Endothel to Endothel" = list(
    "tumor" = c("COLLAGEN", "MIF", "LAMININ", "VISFATIN", "CD99", "SEMA4", "FN1", "PECAM1", "CXCL", "CD46", "CCL", "APP", "ESAM", "PTPRM", "ANGPT", "CDH5"),
    "skin" = c("COLLAGEN", "MIF", "LAMININ", "VISFATIN", "CD99", "SEMA4", "FN1", "PECAM1", "CXCL", "CD46", "CCL", "APP", "ESAM", "PTPRM", "ANGPT", "CDH5")
  )
)

# Find common pathways for each interaction pair
common_pathways_each_pair <- lapply(interactions, function(x) {
  intersect(x$tumor, x$skin)
})

# Find common pathways across all interaction pairs
common_pathways_across_all <- Reduce(intersect, common_pathways_each_pair)

# Print common pathways across all interaction pairs
cat("Common pathways across all interaction pairs:\n")
## Common pathways across all interaction pairs:
print(common_pathways_across_all)
## [1] "COLLAGEN" "LAMININ"  "FN1"      "VISFATIN" "CD99"
# Find pathways that are present in either tumor OR skin for each interaction pair
all_pathways_each_pair <- lapply(interactions, function(x) {
  union(x$tumor, x$skin)
})

# Print pathways for each interaction pair
for (interaction in names(all_pathways_each_pair)) {
  cat("Pathways for interaction", interaction, ":\n")
  print(all_pathways_each_pair[[interaction]])
  cat("\n")
}
## Pathways for interaction Fibroblast_32 to Fibroblast_32 :
##  [1] "COLLAGEN"  "NEGR"      "MK"        "LAMININ"   "TENASCIN"  "SEMA4"    
##  [7] "FN1"       "VISFATIN"  "FGF"       "THBS"      "ncWNT"     "ANGPTL"   
## [13] "TGFb"      "GAS"       "CD99"      "PTPRM"     "JAM"       "CXCL"     
## [19] "PERIOSTIN" "SEMA3"     "PROS"      "CADM"      "PDGF"      "CNTN"     
## [25] "PTN"       "NECTIN"    "TWEAK"     "BMP"       "MIF"       "MPZ"      
## [31] "IGF"       "WNT"      
## 
## Pathways for interaction Fibroblast_36 to Fibroblast_36 :
##  [1] "COLLAGEN"  "ANGPTL"    "LAMININ"   "MK"        "THBS"      "MPZ"      
##  [7] "VISFATIN"  "JAM"       "NEGR"      "IL6"       "SEMA3"     "FN1"      
## [13] "SEMA4"     "FGF"       "GAS"       "TENASCIN"  "ADGRE5"    "PROS"     
## [19] "CXCL"      "NOTCH"     "CD46"      "NECTIN"    "PTN"       "TWEAK"    
## [25] "CD99"      "PERIOSTIN" "HSPG"      "PTPRM"     "EPHA"      "TGFb"     
## [31] "PDGF"      "EPHB"      "CADM"      "MIF"       "IGF"       "WNT"      
## 
## Pathways for interaction Fibroblast_32 to Endothel :
##  [1] "COLLAGEN" "LAMININ"  "MK"       "VISFATIN" "MIF"      "FN1"     
##  [7] "CXCL"     "SEMA4"    "CALCR"    "ANGPTL"   "CD46"     "CCL"     
## [13] "PTN"      "ncWNT"    "VEGF"     "PTPRM"    "CD99"     "SEMA3"   
## [19] "NECTIN"   "APJ"      "PDGF"     "APP"      "IGF"     
## 
## Pathways for interaction Endothel_vasc._31 to Fibroblast_32 :
##  [1] "COLLAGEN"  "SELE"      "LAMININ"   "VISFATIN"  "JAM"       "ANGPT"    
##  [7] "THBS"      "GALECTIN"  "SEMA4"     "CD99"      "SEMA6"     "NOTCH"    
## [13] "PTPRM"     "FN1"       "EDN"       "TENASCIN"  "TGFb"      "PROS"     
## [19] "PERIOSTIN" "SEMA3"     "VCAM"      "CXCL"      "BMP"       "MIF"      
## [25] "GAS"       "MPZ"       "EGF"       "PDGF"      "WNT"      
## 
## Pathways for interaction Fibroblast_32 to Monocyte :
##  [1] "FN1"        "COLLAGEN"   "CD99"       "LAMININ"    "COMPLEMENT"
##  [6] "TENASCIN"   "MK"         "THY1"       "MIF"        "THBS"      
## [11] "CXCL"       "ANNEXIN"    "IL6"        "FGF"        "ANGPTL"    
## [16] "GAS"        "CSF"        "MHC-I"      "SEMA3"      "SEMA4"     
## [21] "MHC-II"     "JAM"        "MPZ"        "IL16"       "ICAM"      
## [26] "PROS"       "NECTIN"     "PTN"        "APP"        "TGFb"      
## [31] "VISFATIN"   "VEGF"      
## 
## Pathways for interaction Fibroblast_20 to Endothel :
##  [1] "COLLAGEN" "LAMININ"  "CD99"     "VISFATIN" "MIF"      "FN1"     
##  [7] "VEGF"     "CD46"     "SEMA4"    "ADGRE5"   "CCL"      "ESAM"    
## [13] "PDGF"     "ANGPT"    "APP"      "PTPRM"   
## 
## Pathways for interaction Fibroblast_32 to Fibroblast_20 :
##  [1] "LAMININ"   "MK"        "CD99"      "CD46"      "COLLAGEN"  "GAS"      
##  [7] "PERIOSTIN" "THBS"      "VISFATIN"  "ncWNT"     "NEGR"      "CALCR"    
## [13] "MPZ"       "HSPG"      "JAM"       "FN1"       "PTN"       "PROS"     
## [19] "NECTIN"    "PDGF"      "CSF"       "PTPRM"     "BMP"       "EPHA"     
## [25] "IGF"      
## 
## Pathways for interaction Fibroblast_18 to Endothel :
##  [1] "COLLAGEN" "LAMININ"  "VISFATIN" "FN1"      "ncWNT"    "SEMA4"   
##  [7] "CXCL"     "VEGF"     "ANGPTL"   "MIF"      "APP"      "CD46"    
## [13] "SEMA3"    "PTN"      "MK"       "CCL"      "NECTIN"   "PTPRM"   
## [19] "APJ"      "CALCR"    "PDGF"     "CD99"     "IGF"     
## 
## Pathways for interaction Fibroblast_18 to Fibroblast_36 :
##  [1] "COLLAGEN"  "THBS"      "LAMININ"   "ANGPTL"    "FGF"       "ncWNT"    
##  [7] "VISFATIN"  "SEMA4"     "IL6"       "NEGR"      "SEMA3"     "GAS"      
## [13] "MPZ"       "FN1"       "CADM"      "TENASCIN"  "PTN"       "TGFb"     
## [19] "JAM"       "MK"        "PROS"      "PTPRM"     "EPHA"      "NECTIN"   
## [25] "CD46"      "PDGF"      "HSPG"      "CD99"      "MIF"       "PERIOSTIN"
## [31] "CXCL"      "IGF"      
## 
## Pathways for interaction Endothel to Endothel :
##  [1] "COLLAGEN" "MIF"      "LAMININ"  "VISFATIN" "CD99"     "SEMA4"   
##  [7] "FN1"      "PECAM1"   "CXCL"     "CD46"     "CCL"      "APP"     
## [13] "ESAM"     "PTPRM"    "ANGPT"    "CDH5"
# Find unique pathways across all interaction pairs
all_unique_pathways <- unique(unlist(all_pathways_each_pair))

# Print all unique pathways across all interaction pairs
cat("All unique pathways across all interaction pairs:\n")
## All unique pathways across all interaction pairs:
print(all_unique_pathways)
##  [1] "COLLAGEN"   "NEGR"       "MK"         "LAMININ"    "TENASCIN"  
##  [6] "SEMA4"      "FN1"        "VISFATIN"   "FGF"        "THBS"      
## [11] "ncWNT"      "ANGPTL"     "TGFb"       "GAS"        "CD99"      
## [16] "PTPRM"      "JAM"        "CXCL"       "PERIOSTIN"  "SEMA3"     
## [21] "PROS"       "CADM"       "PDGF"       "CNTN"       "PTN"       
## [26] "NECTIN"     "TWEAK"      "BMP"        "MIF"        "MPZ"       
## [31] "IGF"        "WNT"        "IL6"        "ADGRE5"     "NOTCH"     
## [36] "CD46"       "HSPG"       "EPHA"       "EPHB"       "CALCR"     
## [41] "CCL"        "VEGF"       "APJ"        "APP"        "SELE"      
## [46] "ANGPT"      "GALECTIN"   "SEMA6"      "EDN"        "VCAM"      
## [51] "EGF"        "COMPLEMENT" "THY1"       "ANNEXIN"    "CSF"       
## [56] "MHC-I"      "MHC-II"     "IL16"       "ICAM"       "ESAM"      
## [61] "PECAM1"     "CDH5"

Violin plots

Here I create new graphs for abs(Interaction_Difference_abs) top10 interactions.

# Filter to get the top 10 interactions by absolute difference
top_10_diff <- merged_df.interactions%>%
  dplyr::ungroup() %>% # Calculate differences without grouping by 'source'
  dplyr::arrange(-abs(Interaction_Difference_abs)) %>%
  dplyr::slice_head(n = 10)

print(top_10_diff)
## # A tibble: 10 × 6
##    source     target Tumor_Interactions Skin_Interactions Interaction_Difference
##    <fct>      <fct>               <int>             <int>                  <int>
##  1 Fibroblas… Kerat…                 74                74                      0
##  2 Fibroblas… Fibro…                 71               111                    -40
##  3 Fibroblas… Kerat…                 65                87                    -22
##  4 Fibroblas… Fibro…                 75                84                     -9
##  5 Fibroblas… T fh                   65                56                      9
##  6 Fibroblas… Kerat…                 61                56                      5
##  7 Endothel_… T fh                   56                59                     -3
##  8 Schwann_43 Kerat…                 45                56                    -11
##  9 Fibroblas… Kerat…                 66                80                    -14
## 10 Endothel   Kerat…                 50                34                     16
## # ℹ 1 more variable: Interaction_Difference_abs <int>
# Plot top 10 interactions with biggest differences 
difference_plot <- ggplot(
  top_10_diff, 
  aes(
    x = paste(source, target, sep = "-"), 
    y = Interaction_Difference_abs,
    fill = Interaction_Difference_abs > 0)
  ) +
  geom_bar(
    stat = "identity",
    position = "dodge"
    ) +
  scale_fill_manual(
    values = c(
      "TRUE" = rgb(178/255, 24/255, 43/255),
      "FALSE" = rgb(33/255, 102/255, 172/255)
      ),
                    labels = c(
                      "TRUE" = "Tumor",
                      "FALSE" = "Skin")
    ) +
  theme_minimal() +
  labs(
    title = "Top 10 according to Interaction_Difference_abs (Tumor - Skin)", 
    y = "Difference in Interactions", 
    x = "Interaction (Source-target)") +
  theme(axis.text.x = element_text(
    angle = 90, 
    hjust = 1)
    )

print(difference_plot)

ggsave("~/rocker/RDEB/thesis/Top_10_Interaction_Difference_abs.png", 
       plot = difference_plot, 
       width = 10, 
       height = 8, 
       dpi = 300)

# Now, let's loop over these top 10 interactions and create the desired plots.
for (i in 1:nrow(top_10_diff)) {
  current_source <- top_10_diff$source[i]
  current_target <- top_10_diff$target[i]

  # Filter the merged_data for the current pair.
  current_data <- merged_data %>%
    filter(source == current_source, 
           target == current_target)

  # Plot
  p <- ggplot(
    current_data, 
    aes(
      x = ligand, 
      y = receptor, 
      fill = prob.delta)
    ) +
    geom_tile() +
    scale_fill_gradient2(
      low = rgb(33/255, 102/255, 172/255), 
      high = rgb(178/255, 24/255, 43/255), 
      mid = "grey", 
      midpoint = 0,
      limits = c(min(current_data$prob.delta, na.rm = TRUE), 
                 max(current_data$prob.delta, na.rm = TRUE)),
      name = "Prob Delta") +
    labs(title = paste("Ligand-Receptor Interactions for",
                       current_source,
                       "to",
                       current_target),
         x = "Ligand",
         y = "Receptor"
         ) +
    theme_minimal() +
    theme(axis.text.x = element_text(
      angle = 90, 
      vjust = 0.5
      ),
          axis.text.y = element_text(hjust = 1))
   
  print(p)

  # Save the plot
  file_name <- paste0("~/rocker/RDEB/thesis/interaction_plots_abs/",
                      current_source,
                      "_to_",
                      current_target, 
                      "_abs_",
                      ".pdf"
                      )
  ggsave(
    file_name,
    plot = p,
    width = 10,
    height = 10
    )
  
  # Extracting the relevant interactions from merged_data for the current interaction pair
  filtered_data <- current_data %>%
    distinct(pathway_name)  # Getting unique pathway names involved in these interactions

  # Print the pathways involved in the current interaction pair
  cat("Pathways for interaction", current_source, "to", current_target, ":\n")
  print(filtered_data)

  # Check if these pathways are in the provided pathways lists
  pathways_involved_t <- filtered_data$pathway_name %in% pathways.show.t
  pathways_involved_s <- filtered_data$pathway_name %in% pathways.show.s

  # Print pathways involved both in tumor and skin for the current interaction pair
  cat("Pathways in Tumor:\n")
  print(filtered_data$pathway_name[pathways_involved_t])
  cat("Pathways in Skin:\n")
  print(filtered_data$pathway_name[pathways_involved_s])
}

## Pathways for interaction 8 to 11 :
##    pathway_name
## 1      COLLAGEN
## 2       LAMININ
## 3           FN1
## 4           MIF
## 5          THBS
## 6            MK
## 7      VISFATIN
## 8           APP
## 9          CD99
## 10     TENASCIN
## 11        ncWNT
## 12          PTN
## 13         CD46
## 14          JAM
## 15          MPZ
## 16          IGF
## Pathways in Tumor:
##  [1] "COLLAGEN" "LAMININ"  "FN1"      "MIF"      "THBS"     "MK"      
##  [7] "VISFATIN" "APP"      "CD99"     "TENASCIN" "ncWNT"    "PTN"     
## [13] "CD46"     "JAM"      "MPZ"      "IGF"     
## Pathways in Skin:
##  [1] "COLLAGEN" "LAMININ"  "FN1"      "MIF"      "THBS"     "MK"      
##  [7] "VISFATIN" "APP"      "CD99"     "TENASCIN" "ncWNT"    "PTN"     
## [13] "CD46"     "JAM"      "MPZ"      "IGF"

## Pathways for interaction 9 to 9 :
##    pathway_name
## 1      COLLAGEN
## 2        ANGPTL
## 3       LAMININ
## 4            MK
## 5          THBS
## 6           MPZ
## 7      VISFATIN
## 8           JAM
## 9          NEGR
## 10          IL6
## 11        SEMA3
## 12          FN1
## 13        SEMA4
## 14          FGF
## 15          GAS
## 16     TENASCIN
## 17       ADGRE5
## 18         PROS
## 19         CXCL
## 20        NOTCH
## 21         CD46
## 22       NECTIN
## 23          PTN
## 24        TWEAK
## 25         CD99
## 26    PERIOSTIN
## 27         HSPG
## 28        PTPRM
## 29         EPHA
## 30         TGFb
## 31         PDGF
## 32         EPHB
## 33         CADM
## 34          MIF
## 35          IGF
## 36          WNT
## Pathways in Tumor:
##  [1] "COLLAGEN"  "ANGPTL"    "LAMININ"   "MK"        "THBS"      "MPZ"      
##  [7] "VISFATIN"  "JAM"       "NEGR"      "IL6"       "SEMA3"     "FN1"      
## [13] "SEMA4"     "FGF"       "GAS"       "TENASCIN"  "ADGRE5"    "PROS"     
## [19] "CXCL"      "NOTCH"     "CD46"      "NECTIN"    "PTN"       "TWEAK"    
## [25] "CD99"      "PERIOSTIN" "HSPG"      "PTPRM"     "EPHA"      "TGFb"     
## [31] "PDGF"      "EPHB"      "CADM"      "MIF"       "IGF"       "WNT"      
## Pathways in Skin:
##  [1] "COLLAGEN"  "ANGPTL"    "LAMININ"   "MK"        "THBS"      "MPZ"      
##  [7] "VISFATIN"  "JAM"       "NEGR"      "IL6"       "SEMA3"     "FN1"      
## [13] "SEMA4"     "FGF"       "GAS"       "TENASCIN"  "ADGRE5"    "PROS"     
## [19] "CXCL"      "NOTCH"     "CD46"      "NECTIN"    "PTN"       "TWEAK"    
## [25] "CD99"      "PERIOSTIN" "HSPG"      "PTPRM"     "EPHA"      "TGFb"     
## [31] "PDGF"      "EPHB"      "CADM"      "MIF"       "IGF"       "WNT"

## Pathways for interaction 9 to 11 :
##    pathway_name
## 1      COLLAGEN
## 2          THBS
## 3           FN1
## 4       LAMININ
## 5           MIF
## 6            MK
## 7           APP
## 8      TENASCIN
## 9      VISFATIN
## 10          PTN
## 11          JAM
## 12         CD46
## 13          MPZ
## 14         CD99
## 15          IGF
## Pathways in Tumor:
##  [1] "COLLAGEN" "THBS"     "FN1"      "LAMININ"  "MIF"      "MK"      
##  [7] "APP"      "TENASCIN" "VISFATIN" "PTN"      "JAM"      "CD46"    
## [13] "MPZ"      "CD99"     "IGF"     
## Pathways in Skin:
##  [1] "COLLAGEN" "THBS"     "FN1"      "LAMININ"  "MIF"      "MK"      
##  [7] "APP"      "TENASCIN" "VISFATIN" "PTN"      "JAM"      "CD46"    
## [13] "MPZ"      "CD99"     "IGF"

## Pathways for interaction 8 to 9 :
##    pathway_name
## 1      COLLAGEN
## 2            MK
## 3       LAMININ
## 4          THBS
## 5          NEGR
## 6           FGF
## 7      VISFATIN
## 8           IL6
## 9         ncWNT
## 10         TGFb
## 11        SEMA4
## 12          JAM
## 13          FN1
## 14     TENASCIN
## 15         CADM
## 16         CXCL
## 17          GAS
## 18          MPZ
## 19        PTPRM
## 20          PTN
## 21    PERIOSTIN
## 22         PROS
## 23       ANGPTL
## 24        SEMA3
## 25         HSPG
## 26        TWEAK
## 27         PDGF
## 28         EPHA
## 29       NECTIN
## 30         CD46
## 31          MIF
## 32         CD99
## 33          BMP
## 34          IGF
## 35          WNT
## Pathways in Tumor:
##  [1] "COLLAGEN"  "MK"        "LAMININ"   "THBS"      "NEGR"      "FGF"      
##  [7] "VISFATIN"  "IL6"       "ncWNT"     "TGFb"      "SEMA4"     "JAM"      
## [13] "FN1"       "TENASCIN"  "CADM"      "CXCL"      "GAS"       "MPZ"      
## [19] "PTPRM"     "PTN"       "PERIOSTIN" "PROS"      "ANGPTL"    "SEMA3"    
## [25] "HSPG"      "TWEAK"     "PDGF"      "EPHA"      "NECTIN"    "CD46"     
## [31] "MIF"       "CD99"      "BMP"       "IGF"       "WNT"      
## Pathways in Skin:
##  [1] "COLLAGEN"  "MK"        "LAMININ"   "THBS"      "NEGR"      "FGF"      
##  [7] "VISFATIN"  "IL6"       "ncWNT"     "TGFb"      "SEMA4"     "JAM"      
## [13] "FN1"       "TENASCIN"  "CADM"      "CXCL"      "GAS"       "MPZ"      
## [19] "PTPRM"     "PTN"       "PERIOSTIN" "PROS"      "ANGPTL"    "SEMA3"    
## [25] "HSPG"      "TWEAK"     "PDGF"      "EPHA"      "NECTIN"    "CD46"     
## [31] "MIF"       "CD99"      "BMP"       "IGF"       "WNT"

## Pathways for interaction 8 to 24 :
##    pathway_name
## 1            MK
## 2       LAMININ
## 3      COLLAGEN
## 4          THBS
## 5           IL2
## 6          THY1
## 7           FN1
## 8          CXCL
## 9           IL6
## 10        MHC-I
## 11         ICAM
## 12         CLEC
## 13        PTPRM
## 14         CD99
## 15          JAM
## 16          PTN
## 17         CADM
## 18          MIF
## 19       NECTIN
## 20         IL16
## 21        TRAIL
## 22          APP
## 23         TGFb
## 24          BMP
## 25         EPHA
## Pathways in Tumor:
##  [1] "MK"       "LAMININ"  "COLLAGEN" "THBS"     "IL2"      "THY1"    
##  [7] "FN1"      "CXCL"     "IL6"      "MHC-I"    "ICAM"     "CLEC"    
## [13] "PTPRM"    "CD99"     "JAM"      "PTN"      "CADM"     "MIF"     
## [19] "NECTIN"   "IL16"     "TRAIL"    "APP"      "TGFb"     "BMP"     
## [25] "EPHA"    
## Pathways in Skin:
##  [1] "MK"       "LAMININ"  "COLLAGEN" "THBS"     "IL2"      "THY1"    
##  [7] "FN1"      "CXCL"     "IL6"      "MHC-I"    "ICAM"     "CLEC"    
## [13] "PTPRM"    "CD99"     "JAM"      "PTN"      "CADM"     "MIF"     
## [19] "NECTIN"   "IL16"     "TRAIL"    "APP"      "TGFb"     "BMP"     
## [25] "EPHA"

## Pathways for interaction 6 to 11 :
##    pathway_name
## 1      COLLAGEN
## 2       LAMININ
## 3           MIF
## 4           FN1
## 5          CD99
## 6      VISFATIN
## 7          THBS
## 8          CD46
## 9           APP
## 10          JAM
## 11       ADGRE5
## 12     TENASCIN
## 13          MPZ
## Pathways in Tumor:
##  [1] "COLLAGEN" "LAMININ"  "MIF"      "FN1"      "CD99"     "VISFATIN"
##  [7] "THBS"     "CD46"     "APP"      "JAM"      "ADGRE5"   "TENASCIN"
## [13] "MPZ"     
## Pathways in Skin:
##  [1] "COLLAGEN" "LAMININ"  "MIF"      "FN1"      "CD99"     "VISFATIN"
##  [7] "THBS"     "CD46"     "APP"      "JAM"      "ADGRE5"   "TENASCIN"
## [13] "MPZ"

## Pathways for interaction 3 to 24 :
##    pathway_name
## 1          SELE
## 2       LAMININ
## 3      COLLAGEN
## 4          THBS
## 5          ICAM
## 6      GALECTIN
## 7        PECAM1
## 8        NECTIN
## 9          CD99
## 10         CXCL
## 11       MHC-II
## 12        ALCAM
## 13        TRAIL
## 14        PTPRM
## 15          FN1
## 16         CLEC
## 17          BMP
## 18          JAM
## 19         TGFb
## 20        NOTCH
## 21          IL6
## 22        MHC-I
## 23          MIF
## 24          APP
## 25         EPHB
## 26         EPHA
## Pathways in Tumor:
##  [1] "SELE"     "LAMININ"  "COLLAGEN" "THBS"     "ICAM"     "GALECTIN"
##  [7] "PECAM1"   "NECTIN"   "CD99"     "CXCL"     "MHC-II"   "ALCAM"   
## [13] "TRAIL"    "PTPRM"    "FN1"      "CLEC"     "BMP"      "JAM"     
## [19] "TGFb"     "NOTCH"    "IL6"      "MHC-I"    "MIF"      "APP"     
## [25] "EPHB"     "EPHA"    
## Pathways in Skin:
##  [1] "SELE"     "LAMININ"  "COLLAGEN" "THBS"     "ICAM"     "PECAM1"  
##  [7] "NECTIN"   "CD99"     "CXCL"     "MHC-II"   "ALCAM"    "TRAIL"   
## [13] "PTPRM"    "FN1"      "CLEC"     "BMP"      "JAM"      "TGFb"    
## [19] "NOTCH"    "IL6"      "MHC-I"    "MIF"      "APP"      "EPHB"    
## [25] "EPHA"

## Pathways for interaction 22 to 11 :
##    pathway_name
## 1      COLLAGEN
## 2          RELN
## 3           FN1
## 4       LAMININ
## 5           PTN
## 6           APP
## 7      VISFATIN
## 8      TENASCIN
## 9           MPZ
## 10          JAM
## 11         THBS
## 12          EGF
## 13         CD46
## Pathways in Tumor:
##  [1] "COLLAGEN" "RELN"     "FN1"      "LAMININ"  "PTN"      "APP"     
##  [7] "VISFATIN" "TENASCIN" "MPZ"      "JAM"      "THBS"     "EGF"     
## [13] "CD46"    
## Pathways in Skin:
##  [1] "COLLAGEN" "FN1"      "LAMININ"  "PTN"      "APP"      "VISFATIN"
##  [7] "TENASCIN" "MPZ"      "JAM"      "THBS"     "EGF"      "CD46"

## Pathways for interaction 5 to 11 :
##    pathway_name
## 1      COLLAGEN
## 2       LAMININ
## 3           FN1
## 4          THBS
## 5      VISFATIN
## 6           APP
## 7      TENASCIN
## 8           PTN
## 9            MK
## 10         CD46
## 11          JAM
## 12          MPZ
## 13         CD99
## 14          IGF
## Pathways in Tumor:
##  [1] "COLLAGEN" "LAMININ"  "FN1"      "THBS"     "VISFATIN" "APP"     
##  [7] "TENASCIN" "PTN"      "MK"       "CD46"     "JAM"      "MPZ"     
## [13] "CD99"     "IGF"     
## Pathways in Skin:
##  [1] "COLLAGEN" "LAMININ"  "FN1"      "THBS"     "VISFATIN" "APP"     
##  [7] "TENASCIN" "PTN"      "MK"       "CD46"     "JAM"      "MPZ"     
## [13] "CD99"     "IGF"

## Pathways for interaction 2 to 11 :
##    pathway_name
## 1      COLLAGEN
## 2           MIF
## 3          SELE
## 4           APP
## 5       LAMININ
## 6          CD99
## 7           FN1
## 8          THBS
## 9           EGF
## 10         CD46
## Pathways in Tumor:
##  [1] "COLLAGEN" "MIF"      "SELE"     "APP"      "LAMININ"  "CD99"    
##  [7] "FN1"      "THBS"     "EGF"      "CD46"    
## Pathways in Skin:
##  [1] "COLLAGEN" "MIF"      "SELE"     "APP"      "LAMININ"  "CD99"    
##  [7] "FN1"      "THBS"     "EGF"      "CD46"